"""
UDP 文件客户端
"""
from socket import *

# 服务器地址
HOST = '127.0.0.1'
PORT = 8888
ADDR = (HOST, PORT)

# 创建套接字
sockfd = socket(AF_INET, SOCK_DGRAM)
source_path = input('请输入原文件路径地址:')
with open(source_path,mode='rb') as file:
    while True:
        send_data = file.read(1024)
        if not send_data:
            break
        sockfd.sendto(send_data, ADDR)
# 接收消息
msg, addr = sockfd.recvfrom(1024)
print("From server:", msg.decode())

# 关闭套接字
sockfd.close()
